/*
** Copyright (C) 2010 Calin Radoni
**
** This file is part of CHScanner.
**
** CHScanner is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** CHScanner is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with CHScanner. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include <winsock2.h>

class MAddressIP
{
private:
	in_addr ia;

public:
	MAddressIP(void);
	~MAddressIP(void);

	void Set(DWORD);
	void Set(BYTE, BYTE, BYTE, BYTE);
	void Set(CString);

	DWORD   GetD(void);
	bool    GetB(BYTE*, BYTE*, BYTE*, BYTE*);
	CString GetS(void);

	void Initialize(void);
	void LoadFromPointer(MAddressIP*);

	bool IsEmpty(void);

	int CompareWith(MAddressIP*);

	// Return the network address given the mask
	DWORD GetNetworkAddress(DWORD);
	// Return the broadcast address given the mask
	DWORD GetBroadcastAddress(DWORD);
	// Returns the network range given the mask
	CString GetNetworkRange(DWORD);

	// Returns a formated network range given the mask
	/*
	DO NOT USE THIS !!!
	DO NOT USE THIS !!!
	DO NOT USE THIS !!!
	Pentru ca 192.168.2-3.1-254 devine:
		192.168.2.1-254
		+
		192.168.3.1-254
	si pierde adresa 192.168.2.255 !!!
	*/
	CString GetNetworkRangeEx(DWORD);
};
